<template>
  <div>
     <div class="block">
         <span class="demonstration">开始</span>
         <el-date-picker
           v-model="value1"
           type="month"
           placeholder="选择月">
         </el-date-picker>
       </div>
       <div class="block" style="position: relative;top: -40px ;left: 270px;">
           <span class="demonstration">结束</span>
           <el-date-picker
             v-model="value2"
             type="month"
             placeholder="选择月">
           </el-date-picker>
<el-link icon="el-icon-edit" @click="selByCondition()" type="primary">查询</el-link>
         </div>

  <el-table :data="tableData" border style="width: 100%" id="out-table">
          <el-table-column prop="projectName" label="项目名称" width="180">
          </el-table-column>
          <el-table-column prop="assignedTime" label="登记时间" width="180">
          </el-table-column>
          <el-table-column prop="assignee" label="登记人">
          </el-table-column>
          <el-table-column prop="actWorkHours" label="登记工时">
          </el-table-column>
        </el-table>
  </div>
</template>

<script>
  export default{
    name:"monthworktime",
    data(){
      return {
              projectId: '',
              value1: '', //时间数据
              value2: '',
              options: [],
              value: '',
              tableData: [],

            }
    },
    mounted(){
          this.findAllMonthlyReport();
          // this.findAllProjectIdAndName();
        },
        methods:{
          save() {
            var wb = this.$xlsx.utils.table_to_book(document.querySelector('#out-table')) //table标签绑定的类名
            /* get binary string as output */
            var wbout = this.$xlsx.write(wb, {
              bookType: 'xlsx',
              bookSST: true,
              type: 'array'
            })
            try {
              this.$fileSaver.saveAs(new Blob([wbout], {
                type: 'application/octet-stream'
              }), '工时日报.xlsx') //导出文件的名字
            } catch (e) {
              if (typeof console !== 'undefined') console.log(e, wbout)
            }
            return wbout

          },
          // findAllProjectIdAndName() {
          //   this.$http.get("/project/getAllProjectIdAndName").then(resp => {
          //     var b = [];
          //     for (var i in resp.data.data) {
          //       var obj = new Object();
          //       obj.value = resp.data.data[i].projectId;
          //       obj.label = resp.data.data[i].projectName;
          //       b[i] = obj;
          //     }
          //     b.push({
          //       value: "",
          //       label: "全部"
          //     })
          //     this.options = b;
          //     console.log(b)
          //   })
          // },
          findAllMonthlyReport(){
            this.$http.get("/worktimeLog/findAallMonthlyReport").then(resp=>{
               this.tableData = resp.data.data;
            })
          },
          selByCondition(){
            this.$http.get("/worktimeLog/findAallMonthlyReport",{
              params:{
                "stime":this.value1,
                "ctime":this.value2
              }
            }).then(resp=>{
              this.tableData = resp.data.data;
            })
          }
        }

  }
</script>

<style>
</style>
